Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

awesome-code-frame

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-code-frame

Fork of @babel/code-frame with modern dependencies and exports

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by38.66%
Maintainers
1
Weekly downloads
 
Created
Source

npm version downloads build status coverage status

awesome-code-frame

What is this?

This is a fork of @babel/code-frame with the latest dependencies (e.g of chalk) and exported as a pure ESM package. It uses the latest chalk, which means it requires support for package imports. If this causes problems in Jest for you, see this issue for help.

Usage

The package exports a function codeFrameColumns() which works just like @babel/code-frame although all dependent types are exported too.

codeFrameColumns( rawLines: string, loc: NodeLocation, opts?: Options ): string;

where NodeLocation is defined as:

interface NodeLocation {
    start: Location;
    end?: Location;
}

Location as:

interface Location {
    column: number;
    line: number;
};

and Options as:

export interface Options {
  /**
   * Syntax highlight the code as JavaScript for terminals. default: false
   * */
  highlightCode?: boolean;
  /**
   * The number of lines to show above the error. default: 2
   * */
  linesAbove?: number;
  /**
   * The number of lines to show below the error. default: 3
   * */
  linesBelow?: number;
  /**
   * Forcibly syntax highlight the code as JavaScript (for non-terminals);
   * overrides highlightCode.
   * default: false
   */
  forceColor?: boolean;
  /**
   * Pass in a string to be displayed inline (if possible) next to the
   * highlighted location in the code. If it can't be positioned inline,
   * it will be placed above the code frame.
   * default: nothing
   */
  message?: string;
}

Keywords

FAQs

Package last updated on 04 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc